home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9967 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: ix.netcom.com!news
  2. From: ave@ix.netcom.com(Alexander Berdichevsky )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question about visibility of local variables
  5. Date: 5 Mar 1996 12:37:04 GMT
  6. Organization: Netcom
  7. Message-ID: <4hhchg$g0p@dfw-ixnews1.ix.netcom.com>
  8. References: <4hfkpc$9em@guardian.forbin.com>
  9. NNTP-Posting-Host: ix-prn1-11.ix.netcom.com
  10. X-NETCOM-Date: Tue Mar 05  6:37:04 AM CST 1996
  11.  
  12. In <4hfkpc$9em@guardian.forbin.com> genesis@forbin.com (Dances with
  13. Demons) writes: 
  14. >
  15. >I am in the process of learning C++ which surprised me in being 
  16. >as awesome as everyone kept telling me.  It is literally better
  17. >than anything I ever expected.  I ran into one dark area for me
  18. >in the area of automatic variables. 
  19. >   It said in the book I'm studying, "Object-Oriented Programming
  20. >in C++, by Robert Lafore", that when a function is executed, the
  21. >and the variable is defined, it will continue to exist until the
  22. >function is exited.  When this happens, the memory that the variable
  23. >is freed up and is used by other variables/function calls, etc.
  24. >
  25. >The question is:  When you define a variable in main(), and call
  26. another 
  27. >function, or even when defining a local variable in a function that
  28. calls 
  29. >another function, why are the local variables not destroyed.
  30.  
  31. All local variables are destroyed after the function is done (after
  32. return clause). When the function calls another function it is not done
  33. yet.
  34.  
  35. If it is not enough feel free to email more detail question to me.
  36.  
  37. Alex
  38.  
  39.